<!doctype html>
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
<?php use_helper('I18N') ?>
    <?php include('scripts.php'); ?>

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- CSS Styles -->
	<link rel="stylesheet" href="/css/style.css">
	<link rel="stylesheet" href="/css/colors.css">

	<!-- Google WebFonts -->
	<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
    <style type="text/css">
    .redbutton {
        background:#ae432e url('/css/images/btns/btn_red.png') repeat-x left top;
    }
    </style>
    <script>
	$(function() {
        $("#lang").change(function() {
            $("#doAction").val("lang");
            $("#loginForm").submit();
        });

        $("#btnLogin").click(function(){

        });

        $("#captchaimage").bind('click', function() {
            $.post('/captcha/newSession');
            $("#captchaimage").load('/captcha/imageRequest');
            return false;
        });

        $("#loginForm").validate({
            rules: {
                <?php if (sfConfig::get('sf_environment') == Globals::SF_ENVIRONMENT_PROD) { ?>
                captcha: {
                    required: true,
                    remote: "/captcha/process"
                }
                <?php } ?>
            },
            messages: {
                captcha: "Correct captcha is required."
            },
            submitHandler: function(form) {
                if ("" == $("#doAction").val()) {
                    <?php if (sfConfig::get('sf_environment') == Globals::SF_ENVIRONMENT_PROD) { ?>
                    if ($.trim($("#username").val()) == "") {
                        alert("Shareholder ID cannot be blank.");
                        $("#username").focus();
                        return false;
                    }
                    if ($.trim($("#userpassword").val()) == "") {
                        alert("Password cannot be blank.");
                        $("#userpassword").focus();
                        return false;
                    }
                    <?php } ?>
                }

                form.submit();
            }
        });
	});
	</script>
</head>
<body class="login">
	<section role="main">

		<div><img src="/images/logo.png" alt="OFX GLOBAL" style="height: 50px"></div>

		<!-- Login box -->
		<article id="login-box">

			<div class="article-container">

				<form action="/home/doLogin" id="loginForm" method="post">
                    <input type="hidden" name="doAction" id="doAction" value="">
					<fieldset>
						<dl>
							<dt>
								<label><?php echo __('User Name') ?></label>
							</dt>
							<dd>
								<input type="text" name="username" id="username" class="large" value="<?php echo $username; ?>">
							</dd>
							<dt>
								<label><?php echo __('Password') ?></label>
							</dt>
							<dd>
								<input type="password" name="userpassword" id="userpassword" class="large" value="<?php echo $userpassword; ?>">
							</dd>
							<dt>
								<label><?php echo __('Language') ?></label>
							</dt>
							<dd>
								<select name="lang" id="lang">
                                    <option value="en"
                                      <?php
                                        if ($sf_user->getCulture() == "en")
                                        echo 'selected'
                                        ?>
                                        >English</option>
                                    <option value="cn"
                                      <?php
                                        if ($sf_user->getCulture() == "cn")
                                        echo 'selected'
                                        ?>
                                    >中文</option>
                                </select>
							</dd>
						</dl>
					</fieldset>
                    <?php if ($sf_flash->has('errorMsg')) { ?>
                        <div class="notification error">
                            <p><strong><?php echo $sf_flash->get('errorMsg') ?></strong></p>
                        </div>
                    <?php }
                    if ($appSetting->getSettingValue()=='0') {
                    ?>
					<button type="submit" class="right redbutton"><?php echo __('Login') ?></button>
                    <?php } ?>
				</form>

			</div>

		</article>
		<!-- /Login box -->
		<ul class="login-links">
			<li><a href="/member/register"><?php echo __('Register') ?></a></li>
			<li><a href="#"><?php echo __('Forget Password?') ?></a></li>
		</ul>

	</section>
</body>
</html>